package risk.control.project.utils.aes;

import org.apache.commons.codec.binary.Hex;

import java.util.HexFormat;

public class TestCBC_02 {
    public static void main(String[] args) {
        String key = "QHilvk7D3Phq766hQHilvk7D3Phq766h";
        //等价于：CryptoJS.enc.Utf8.parse(key)
        String s = HexFormat.of().formatHex(key.getBytes());//转为十六进制字符串

        String encrypt = CBC_Encryption.encrypt(s, "这是阿斯蒂芬空间哈上岛咖啡几哈啊束带结发阿克苏发的");
        System.out.println(encrypt);
        System.out.println("------------------");
        String decrypt = CBC_Encryption.decrypt(s, encrypt);
        System.out.println(decrypt);

        System.out.println("1111111");

        //用apache工具类，兼容性更好
        String s1 = Hex.encodeHexString(key.getBytes());
        String encrypt1 = CBC_Encryption.encrypt(s, "这是阿斯蒂芬空间哈上岛咖啡几哈啊束带结发阿克苏发的");
        System.out.println(encrypt1);
        System.out.println("------------------");
        String decrypt1 = CBC_Encryption.decrypt(s, encrypt);
        System.out.println(decrypt1);
    }


}
